$(function () {

    $("#upload_userthum").click(function (e) {
        $("#fileUserInput").click();
    });

    $("#fileUserInput").change(function (e) {
        var formData = new FormData();
        formData.append('image', $('#fileUserInput')[0].files[0]);
        $.ajax({
            url: '/home/upload/picture',
            type: 'POST',
            data: formData,
            cache: false,
            contentType: false,
            processData: false,
            success: function(data) {
                window.location.href = "/home/myhome";
            },
            error: function() {
                console.log('上传失败');
            }
        });
    });

    $("#upload_click").click(function (e) {
        $("#fileInput").click();
    });

    $("#fileInput").change(function (e) {
        var formData = new FormData();
        formData.append('image', $('#fileInput')[0].files[0]);
        $.ajax({
            url: '/home/upload/image',
            type: 'POST',
            data: formData,
            cache: false,
            contentType: false,
            processData: false,
            success: function(data) {
                window.location.href = "/home/upload/"+data.data.id;
            },
            error: function() {
                console.log('上传失败');
            }
        });
    });
});